//
//  Options.m
//  TestMenuSystem
//
//  Created by Ronald Ram on 12/22/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "Options.h"
#import "MainMenu.h"

#import "SceneMgr.h"
//extern CCLayer *sharedMenuPtr;


#pragma mark - Initialization

@implementation Options

- (id) init
{
    if ( self = [super init] )
    {
        //add BG to menu
        CCLayerColor *bg = [CCLayerColor layerWithColor:ccc4(186, 121, 28, 255)];
        [self addChild: bg];
        
        //add menu title
        CCLabelTTF *label = [CCLabelTTF labelWithString: @"Options" fontName: @"Noteworthy" fontSize: 56];
        CGSize size = [CCDirector sharedDirector].winSize;
        label.position = ccp(size.width / 2, size.height - (size.height * 0.15));
        [self addChild: label];
        
        //add a BACK btn
        CCMenuItemFont *item1 = [CCMenuItemFont itemWithString:@"Back" target:self selector:@selector(onClick:)];
        item1.tag = MAIN_MENU;
        
        //add menuItem(s) to menu
        CCMenu *menu = [CCMenu menuWithItems: item1, nil];
        [menu alignItemsVerticallyWithPadding: 10];
        [menu setColor: ccc3(240, 190, 93)];
        
        //add menu to layer
        [self addChild:menu];
        
        id fade1 = [CCFadeIn actionWithDuration: 0.3];
        [bg runAction: fade1];
        
        id fade2 = [CCFadeIn actionWithDuration: 0.3];
        [label runAction: fade2];
    }
    return self;

}


#pragma mark - BBSelectionDelegate methods

+ (CCScene *) scene
{
    CCScene *scene = [CCScene node];
    CCLayer *menu = [Options node];
    
    [scene addChild: menu];
    return scene;
}


- (void) onClick: (CCMenuItemFont *) sender
{
    id action = [CCFadeIn actionWithDuration: 0.5];
    switch (sender.tag)
    {
        default:
//            [[CCDirector sharedDirector] replaceScene: [MainMenu scene]];
//            [ [CCDirector sharedDirector] replaceScene: [CCTransitionMoveInL transitionWithDuration: 0.3 scene: [MainMenu scene]] ];
            [[SceneMgr scene] switchLayer: [MainMenu node] withAction: action];
            break;
    }
}

@end
